#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
    int n;
    int num = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        int sum = 0;
        num = i;
        while (num > 0)
        {
            sum = sum * 10 + num % 10;
            num /= 10;
        }
        if (i == sum)
        {
            printf("%d\n", i);
        }
    }
    return 0;
}